package com.zsrt.java.day20161226.zzd.demo1;

import java.util.Scanner;

public class CalTest01 {
	public static int add(int x ,int y){
		return x+y;
	}
	public static int sub(int x ,int y){
		return x-y;
	}
	public static int mul(int x ,int y){
		return x*y;
	}
	public static int chu(int x ,int y){
		
		if(y==0){
			return 0;
		}
		return x/y;
	}
	public static int mo(int x ,int y){
		return x%y;
	}
	
	public static int cal(String flag,int x, int y){
		int result=0;
		if(flag.equals("+")){
			 result=add(x,y);
		}else if(flag.equals("-")){
			 result=sub(x,y);
		}else if(flag.equals("*")){
			 result=mul(x,y);
		}else if(flag.equals("/")){
			 result=chu(x,y);
		}else if(flag.equals("%")){
			result=mo(x,y);
		}
		return result;
	}
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		while(true){
			
			System.out.println("请输入符号...");
			
			String  flag  = sc.next();
			
			if(flag.equals("quit")){
				break;
			}
			
			System.out.println("请输入第1个数...");
			int x  = sc.nextInt();
			
			System.out.println("请输入第2个数...");
			int y = sc.nextInt();
			
			int abc =cal(flag, x, y);
			System.out.println(abc);
			
		}
		sc.close();
	}

}
